import unittest
import os
from mbsh import create_app, logger
from mbsh.core.db_full_screen import DbScreen
import pandas as pd


class DbScreenTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        app = create_app(os.getenv('FLASK_CONFIG') or 'default')
        app.app_context().push()

    def tearDown(self):
        print('tear down')

    def test_range_time(self):
        db_screen = DbScreen('month')
        start_time, end_time = db_screen.range_time()
        logger.debug(start_time)
        logger.debug(end_time)

    def test_get_report_df(self):
        db_screen = DbScreen('month')
        case_df = db_screen.get_report_df()
        logger.debug(case_df)

    def test_get_last_df(self):
        db_screen = DbScreen('week')
        df = pd.DataFrame()
        last_df = db_screen.get_last_df('adenoma', df)
        logger.debug(last_df)

    def test_full_screen_stomach26(self):
        db_screen = DbScreen('month')
        data_list = db_screen.full_screen_stomach26()
        logger.debug(data_list)

    def test_full_screen_adenoma(self):
        db_screen = DbScreen('month')
        data_list = db_screen.full_screen_adenoma()
        logger.debug(data_list)

    def test_full_copmose_data(self):
        db_screen = DbScreen('month')
        data_list = db_screen.full_copmose_data()
        logger.debug(data_list)

if __name__ == '__main__':
    unittest.main()
